# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libmfx
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.35.1
pkgrel=1
pkgdesc="Intel Media SDK dispatcher library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url="https://github.com/lu-zero/mfx_dispatch/"
license=("BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/lu-zero/mfx_dispatch/archive/${pkgver}.tar.gz")
sha256sums=('673636da98a4fd5c3e3dc5267da5429e986f53089ed6c33cdca5751f56d9416b')

prepare() {
  cd "${srcdir}/mfx_dispatch-${pkgver}"
  autoreconf -fiv
}

build() {
  [[ -d "build-${MSYSTEM}" ]] && rm -rf "build-${MSYSTEM}"
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  export lt_cv_deplibs_check_method='pass_all'

  ../mfx_dispatch-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR=${pkgdir} install
}
